<template>
    <div>
        <v-header></v-header>
        <div class="sec-header">
            <div class="path">
                <span class="home" @click="outcontent"><img src="../../assets/home/home.png"></span> /
                <span>{{ this.projectName }}</span>
            </div>
            <ul class="nav">
                <li v-for="(item ,index) in items" :class="(index == activeIndex)  ? 'choose':''" @click="changePage(index)">
                    <span >{{item}}</span>
                </li>
            </ul>
        </div>
        <router-view></router-view>
    </div>
</template>

<script>
    import header from '@/components/sy/header.vue';
    export default {
        components: {
            'v-header': header
        },
        data() {
            return {
                projectName: localStorage.getItem('projectName'),
                activeIndex: localStorage.getItem('activeIndex'),
                items:["任务","文档","团队","统计"]
            }
        },
        created() {
            console.log(this.activeIndex);
            console.log("111")
            this.activeIndex = (this.activeIndex == "null") ? 0 : localStorage.getItem('activeIndex')
        },
        methods: {
            outcontent () {
                this.$router.push('/');
            },
            changePage(index) {
                this.activeIndex = index;
                localStorage.setItem('activeIndex',index);
                if(index == 0) {
                    this.$router.push({
                        path: '/content',
                        query: {
                            'id': localStorage.getItem('projectId'),
                            'name': localStorage.getItem('projectName')
                        }
                    })
                }else if(index == 1) {
                    this.$router.push('/doc');
                }else if(index == 2){
                    this.$router.push('/team');
                }else {
                    this.$router.push('/sta')
                }
            }
        },
        created () {
            if(this.activeIndex == null) {
                this.activeIndex = 0;
            }else {
                this.activeIndex = localStorage.getItem('activeIndex')
            }
            console.log(this.activeIndex)
            this.changePage(this.activeIndex)
        }
    };

</script>

<style lang="scss" scoped>
    .sec-header {
        width: 100%;
        height: 48px;
        line-height: 48px;
        border-bottom: 1px solid #e7e9f4;
        font-size: 24px;
        background: #f7f8fc;
        color: #4c58a4;
        font-size: 18px;
        .path {
            position: absolute;
            float: left;
            margin-left: 78px;
            cursor: default;
            .home {
                cursor: pointer;
                margin-top: 3px;
                float: left;
                margin-right: 5px;
            }
        }
        .nav {
            float: left;
            margin-left: 80px;
            font-size: 18px;
            li {
                padding: 15px 0;
                display: inline-block;
                padding: 0 20px;
                span {
                    border-bottom: 4px solid #f7f8fc;
                    cursor: pointer;
                }
            }
            li.choose {
                border-bottom: 3px solid #4c58a4;
            }
        }
    }
</style>